//
//  ImageExtension.swift
//  SwfitBase
//
//  Created by rubick on 2023/1/17.
//

import Foundation
import UIKit

extension UIImage {
    convenience init?(rk_color: UIColor) {
        let rect = CGRect(x: 0, y: 0, width: 1, height: 1)
        UIGraphicsBeginImageContext(rect.size)
        rk_color.setFill()
        UIRectFill(rect)
        guard let image: UIImage = UIGraphicsGetImageFromCurrentImageContext(), let cgImage = image.cgImage else {
            UIGraphicsEndImageContext()
            return nil
        }
        UIGraphicsEndImageContext()
        self.init(cgImage: cgImage, scale: UIScreen.main.scale, orientation: .up)
    }
}
